﻿using DB.Dapper;
using Dapper;
/*
namespace YiSha.Service.BLLManage
{
    /// <summary>
    /// 创 建：admin
    /// 日 期：2024-03-04 14:36
    /// 描 述：车辆信息服务类
    /// </summary>
    public class 调用示例 :  RepositoryFactory
    {

        private string mainSql = "select * from ZlCar where 1=1 ";
        #region 获取数据
        public async Task<List<ZlCarEntity>> GetPageList(ZlCarListParam param, Pagination pagination)
        {
            FilterClass filterClass = this.WhereFilter(param);
            SqlMapper.GridReader read = DapperUtils.PaginationZjc(mainSql, pagination.PageIndex, pagination.PageSize, "BaseCreateTime desc", filterClass.where, filterClass.parameters);
            IEnumerable<ZlCarEntity> list = await read.ReadAsync<ZlCarEntity>();
            pagination.TotalCount = await read.ReadFirstAsync<int>();
            return list.ToList();           
        }
        public async Task<List<ZlCarEntity>> GetList(ZlCarListParam param)
        {
            FilterClass filterClass = this.WhereFilter(param);
            List<ZlCarEntity> list = await DapperUtils.queryList<ZlCarEntity>(mainSql, filterClass.parameters, "BaseCreateTime desc", filterClass.where);
            return list;
        }
        private FilterClass WhereFilter(ZlCarListParam param)
        {
            FilterClass filterClass = new FilterClass();
            if (!string.IsNullOrEmpty(param.Id))
            {
                filterClass.where = filterClass.where + " and Id=@Id ";
                filterClass.parameters.Add("@Id", param.Id);
            }

            if (!string.IsNullOrEmpty(param.CarCode))
            {

                filterClass.where = filterClass.where + " and CarCode=@CarCode ";
                filterClass.parameters.Add("@CarCode", param.CarCode);
            }

            if (!string.IsNullOrEmpty(param.CarNo))
            {
                filterClass.where = filterClass.where + " and CarNo like @CarNo ";
                filterClass.parameters.Add("@CarNo", '%' + param.CarNo + '%');
            }

            if (!string.IsNullOrEmpty(param.CarStatus))
            {
                filterClass.where = filterClass.where + " and CarStatus = @CarStatus ";
                filterClass.parameters.Add("@CarStatus", param.CarStatus);
            }

            if (!string.IsNullOrEmpty(param.CarStatusType))
            {
                if (param.CarStatusType == "noSelectChuche")
                {
                    filterClass.where = filterClass.where + " AND (CarStatus = 2 or CarStatus = 3)";
                }
            }
            if (!string.IsNullOrEmpty(param.ShopId))
            {
                filterClass.where = filterClass.where + " and ShopId = @ShopId ";
                filterClass.parameters.Add("@ShopId", param.ShopId);
            }
            return filterClass;
        }
    }
}
*/
